home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_emacs.idb / usr / freeware / info / ediff-1.z / ediff-1
Encoding:
GNU Info File  |  1998-10-28  |  47.3 KB  |  1,073 lines

  1. This is Info file ../info/ediff, produced by Makeinfo-1.63 from the
  2. input file ediff.texi.
  3.  
  4.    This file documents Ediff, a comprehensive visual interface to Unix
  5. diff and patch utilities.
  6.  
  7.    Permission is granted to make and distribute verbatim copies of this
  8. manual provided the copyright notice and this permission notice are
  9. preserved on all copies.
  10.  
  11. 
  12. File: ediff,  Node: Top,  Next: Introduction,  Prev: (dir),  Up: (dir)
  13.  
  14. * Menu:
  15.  
  16. * Introduction::                About Ediff.
  17. * Major Entry Points::          How to use Ediff.
  18. * Commands::                    Ediff commands.
  19. * Registry of Ediff Sessions::  Keeping track of multiple Ediff sessions.
  20. * Session Groups::              Comparing and merging directories.
  21. * Remote and Compressed Files::  You may want to know about this.
  22. * Customization::               How to make Ediff work the way YOU want.
  23. * Credits::                     Thanks to those who helped.
  24. * Index::
  25.  
  26. 
  27. File: ediff,  Node: Introduction,  Next: Major Entry Points,  Prev: Top,  Up: Top
  28.  
  29. Introduction
  30. ************
  31.  
  32.    Ediff provides a convenient way for simultaneous browsing through
  33. the differences between a pair (or a triple) of files or buffers.  The
  34. files being compared, file-A, file-B, and file-C (if applicable) are
  35. shown in separate windows (side by side, one above the another, or in
  36. separate frames), and the differences are highlighted as you step
  37. through them.  You can also copy difference regions from one buffer to
  38. another (and recover old differences if you change your mind).
  39.  
  40.    Another powerful feature is the ability to merge a pair of files
  41. into a third buffer. Merging with an ancestor file is also supported.
  42. Furthermore, Ediff is equipped with directory-level capabilities that
  43. allow the user to conveniently launch browsing or merging sessions on
  44. groups of files in two (or three) different directories.
  45.  
  46.    In addition, Ediff can apply a patch to a file and then let you step
  47. though both files, the patched and the original one, simultaneously,
  48. difference-by-difference.  You can even apply a patch right out of a
  49. mail buffer, i.e., patches received by mail don't even have to be
  50. saved.  Since Ediff lets you copy differences between buffers, you can,
  51. in effect, apply patches selectively (i.e., you can copy a difference
  52. region from `file_orig' to `file', thereby undoing any particular patch
  53. that you don't like).
  54.  
  55.    Ediff even understands multi-file patches and can apply them
  56. interactively!  (Ediff can recognize multi-file patches only if they
  57. are in the context or GNU unified format. All other patches are treated
  58. as 1-file patches. Ediff is [hopefully] using the same algorithm as
  59. patch to determine which files need to be patched.)
  60.  
  61.    Ediff is aware of version control, which lets you compare files with
  62. their older versions. Ediff also works with remote and compressed
  63. files, automatically ftp'ing them over and uncompressing them.  *Note
  64. Remote and Compressed Files::, for details.
  65.  
  66.    This package builds upon ideas borrowed from Emerge and several
  67. Ediff's functions are adaptations from Emerge.  Although Ediff subsumes
  68. Emerge, much of the functionality of Ediff is influenced by Emerge.
  69. The architecture and the interface are, of course, drastically
  70. different.
  71.  
  72. 
  73. File: ediff,  Node: Major Entry Points,  Next: Commands,  Prev: Introduction,  Up: Top
  74.  
  75. Major Entry Points
  76. ******************
  77.  
  78.    Ediff can be invoked interactively using the following functions,
  79. which can be run either from the minibuffer or from the menu bar. In
  80. the menu bar, all Ediff's entry points belong to three submenus of the
  81. Tools menu: Compare, Merge, and Apply Patch.
  82.  
  83. `ediff-files'
  84. `ediff'
  85.      Compare two files.
  86.  
  87. `ediff-buffers'
  88.      Compare two buffers.
  89.  
  90. `ediff-files3'
  91. `ediff3'
  92.      Compare three files.
  93.  
  94. `ediff-buffers3'
  95.      Compare three buffers.
  96.  
  97. `edirs'
  98. `ediff-directories'
  99.      Compare files common to two directories.
  100.  
  101. `edirs3'
  102. `ediff-directories3'
  103.      Compare files common to three directories.
  104.  
  105. `edir-revisions'
  106. `ediff-directory-revisions'
  107.      Compare versions of files in a given directory. Ediff selects only
  108.      the files that are under version control.
  109.  
  110. `edir-merge-revisions'
  111. `ediff-merge-directory-revisions'
  112.      Merge versions of files in a given directory. Ediff selects only
  113.      the files that are under version control.
  114.  
  115. `edir-merge-revisions-with-ancestor'
  116. `ediff-merge-directory-revisions-with-ancestor'
  117.      Merge versions of files in a given directory using other versions
  118.      as ancestors. Ediff selects only the files that are under version
  119.      control.
  120.  
  121. `ediff-windows-wordwise'
  122.      Compare windows word-by-word.
  123.  
  124. `ediff-windows-linewise'
  125.      Compare windows line-by-line.
  126.  
  127. `ediff-regions-wordwise'
  128.      Compare regions word-by-word.
  129.  
  130. `ediff-regions-linewise'
  131.      Compare regions line-by-line.
  132.  
  133. `ediff-revision'
  134.      Compare versions of the current buffer, if the buffer is visiting
  135.      a file under version control.
  136.  
  137. `ediff-patch-file'
  138. `epatch'
  139.      Patch a file, then compare.
  140.  
  141. `ediff-patch-buffer'
  142. `epatch-buffer'
  143.      Patch auffer, then compare.
  144.  
  145. `ediff-merge-files'
  146. `ediff-merge'
  147.      Merge two files.
  148.  
  149. `ediff-merge-files-with-ancestor'
  150. `ediff-merge-with-ancestor'
  151.      Like `ediff-merge', but with a third ancestor file.
  152.  
  153. `ediff-merge-buffers'
  154.      Merge two buffers.
  155.  
  156. `ediff-merge-buffers-with-ancestor'
  157.      Same but with ancestor.
  158.  
  159. `edirs-merge'
  160. `ediff-merge-directories'
  161.      Merge files common to two directories.
  162.  
  163. `edirs-merge-with-ancestor'
  164. `ediff-merge-directories-with-ancestor'
  165.      Same but using files in a third directory as ancestors.
  166.  
  167. `ediff-merge-revisions'
  168.      Merge two versions of the file visited by the current buffer.
  169.  
  170. `ediff-merge-revisions-with-ancestor'
  171.      Same but with ancestor.
  172.  
  173. If you want Ediff to be loaded from the very beginning of your Emacs
  174. session, you should put this line in your `~/.emacs' file:
  175.  
  176.      (require 'ediff)
  177.  
  178. Otherwise, Ediff will be loaded automatically when you use one of the
  179. above functions, either directly or through the menus.
  180.  
  181.    When the above functions are invoked, they prompt the user for the
  182. information they need--typically the files or buffers to compare or
  183. patch. Ediff tries to be smart about these prompts. For instance, in
  184. comparing/merging files, it will offer the visible buffers as defaults.
  185. In prompting for files, if the user enters a directory, the previously
  186. input file name will be appended to that directory. In addition, if the
  187. variable `ediff-use-last-dir' is not `nil', Ediff will offer previously
  188. entered directories as defaults (which will be maintained separately
  189. for each type of file, A, B, or C).
  190.  
  191.    All the above functions use the POSIX `diff' program to find
  192. differences between two files.  They process the `diff' output and
  193. display it in a convenient form.  At present, Ediff understands only the
  194. plain output from diff.  Options such as `-c' are not supported, nor is
  195. the format produced by incompatible file comparison programs such as
  196. the VMS version of `diff'.
  197.  
  198.    The functions `ediff-files', `ediff-buffers', `ediff-files3',
  199. `ediff-buffers3' first display the coarse, line-based difference
  200. regions, as reported by the `diff' program.  Since diff may report
  201. fairly large chunks of text as being different, even though the
  202. difference may be localized to just a few words or even to the white
  203. space or line breaks, Ediff further *refines* the regions to indicate
  204. which exact words differ.  If the only difference is in the white space
  205. and line breaks, Ediff says so.
  206.  
  207.    On a color display, fine differences are highlighted with color; on a
  208. monochrome display, they are underlined.  *Note Highlighting Difference
  209. Regions::, for information on how to customize this.
  210.  
  211.    The functions `ediff-windows-wordwise', `ediff-windows-linewise',
  212. `ediff-regions-wordwise' and `ediff-regions-linewise' do comparison on
  213. parts of existing Emacs buffers.  Since `ediff-windows-wordwise' and
  214. `ediff-regions-wordwise' are intended for relatively small segments of
  215. buffers, comparison is done on the basis of words rather than lines.
  216. No refinement is necessary in this case.  These commands are recommended
  217. only for relatively small regions (perhaps, up to 100 lines), because
  218. these functions have a relatively slow startup.
  219.  
  220.    To compare large regions, use `ediff-regions-linewise'.  This
  221. command displays differences much like `ediff-files' and
  222. `ediff-buffers'.
  223.  
  224.    The functions `ediff-patch-file' and `ediff-patch-buffer' apply a
  225. patch to a file or a buffer and then run Ediff on these buffers,
  226. displaying the difference regions.
  227.  
  228.    The entry points `ediff-directories', `ediff-merge-directories',
  229. etc., provide a convenient interface for comparing and merging files in
  230. different directories. The user is presented with Dired-like interface
  231. from which one can run a group of related Ediff sessions.
  232.  
  233.    For files under version control, `ediff-revisions' lets you compare
  234. the file visited by the current buffer to one of its checked-in
  235. versions.  You can also compare two checked-in versions of the visited
  236. file.  Moreover, the functions `ediff-directory-revisions',
  237. `ediff-merge-directory-revisions', etc., let you run a group of related
  238. Ediff sessions by taking a directory and comparing (or merging)
  239. versions of files in that directory.
  240.  
  241. 
  242. File: ediff,  Node: Commands,  Next: Registry of Ediff Sessions,  Prev: Major Entry Points,  Up: Top
  243.  
  244. Commands
  245. ********
  246.  
  247.    All Ediff commands are displayed in a quick help window, unless you
  248. type `?' to shrink the window to just one line.  You can redisplay the
  249. help window by typing `?' again.  In this section we comment only on
  250. the features that cannot be readily deduced from the quick help window.
  251. You can always type `E' in the control window to display this manual.
  252.  
  253.    Many Ediff commands take numeric prefix arguments.  For instance, if
  254. you type a number, say 3, and then `j' (`ediff-jump-to-difference'),
  255. Ediff moves to the third difference region.   Typing 3 and then `a'
  256. (`ediff-diff-to-diff') copies the 3d difference region from buffer A to
  257. buffer B.  Typing `b' does copying in the opposite direction.  (In
  258. 3-way comparison mode, the commands for copying are `ab', `ba', `ca',
  259. etc.) Likewise, 4 followed by `ra' restores the 4th difference region
  260. in buffer A (if it was previously saved as a result of copying from,
  261. say, buffer B to A).
  262.  
  263.    Some commands take negative prefix arguments as well.  For instance,
  264. typing `-' and then `j' will take Ediff to the last difference. Typing
  265. `-2' then `j' takes Ediff to to the penultimate difference region, etc.
  266.  
  267.    Without the prefix argument, all commands operate on the current
  268. selected difference region.  You can select any difference region as
  269. the current one using other Ediff commands.
  270.  
  271.    For some commands, the value of the prefix argument is immaterial.
  272. However, if supplied, the prefix argument modifies the command.  For
  273. instance, normally the commands `ga'/`gb'/`gc'
  274. (`ediff-jump-to-difference-at-point') causes Ediff to jump to the
  275. difference region that is closest to the point in a specified buffer
  276. (the buffer, A, B, or C, is specified by the last character of the
  277. command, i.e., for `gb', the specified buffer is B).  However, with a
  278. prefix argument, Ediff would position all these buffers around the area
  279. indicated by the current point in the specified buffer: if the point is
  280. inside a difference region, then the buffers will be positioned at this
  281. difference region. If the point is not in any difference region, then
  282. it is in an area where all buffers agree with each other. In this case,
  283. all buffers will be positioned so that they would display this area.
  284.  
  285.    The total number of differences and the current difference number are
  286. always displayed in the mode line of the control window.
  287.  
  288.    If, after making changes to buffers A, B, or C, you decide to save
  289. them, it is best to use `ediff-save-buffer', which is bound to `wa',
  290. `wb', and `wc' (`wa' will save buffer A, `wb' saves buffer B, etc.).
  291.  
  292.    Typing `wd' saves the output from the `diff' utility to a file, so
  293. you can later refer to it. With prefix argument, this command saves the
  294. plain output from `diff' (see `ediff-diff-program' and
  295. `ediff-diff-options'). Without the argument, it saves customized `diff'
  296. output (see `ediff-custom-diff-program' and
  297. `ediff-custom-diff-options'), if it is available.
  298.  
  299.    Instead of saving it, `diff' output can be *displayed* using the
  300. command `D'. Without the prefix argument, it displays the customized
  301. `diff' output of the session.  With the prefix argument, it displays
  302. the plain `diff' output If either of the `diff' outputs is unavailable
  303. (because it wasn't generated or the user killed the respective buffer),
  304. then Ediff will try to display the other `diff' output.  If none is
  305. available, a warning is issued.
  306.  
  307.    The command `z' suspends the current ediff session. It hides the
  308. control buffer and the variants. The easiest way to resume a suspended
  309. Ediff session is through the registry of active sessions.  *Note
  310. Registry of Ediff Sessions::, for details.
  311.  
  312.    The command `q' quits the current Ediff session. With a prefix
  313. argument, it will ask the user whether to delete the variant buffers.
  314.  
  315.    The command `s' is used only for merging.  It shrinks window C (the
  316. merge window) to its minimal size, thereby exposing as much of buffers A
  317. and B as possible.  This command is intended only for temporary viewing;
  318. therefore, Ediff restores window C to its original size whenever it
  319. makes any other change in the window configuration.  Typing `s' again
  320. also restores the original size of window C.  However, recentering and
  321. jumping to a difference does not affect window C's size.
  322.  
  323.    With a positive prefix argument, the command `s' makes the merge
  324. window, window C, slightly taller. With `-' or a negative prefix
  325. argument, `s' makes window C slightly shorter.
  326.  
  327.    Another command used only for merging is `+'.  Its effect is to
  328. combine the current difference regions of buffers A and B and put the
  329. combination into the merge buffer. *Note Merging and diff3::,
  330. specifically, the variables `ediff-combine-diffs' and
  331. `ediff-combination-pattern'.
  332.  
  333.    In merge mode, Ediff uses a default variant (one of the two files
  334. being merged) when it cannot decide which of the difference regions
  335. (that of buffer A or buffer B) should be copied into the merge buffer.
  336. You might decide to use the other variant instead.  To facilitate this,
  337. Ediff has a command, bound to `&', which selects another default
  338. variant for the current difference and subsequent differences.  You can
  339. specify as the new default any of `default-A', `default-B', or
  340. `combined'.  *Note Merging and diff3::, for details.
  341.  
  342.    Such repeated merging affects only difference regions that have
  343. default-A/B status, and only if they were not changed with respect to
  344. their originals.
  345.  
  346.    Some commands are not bound to any key:
  347.  
  348. `eregistry'
  349. `ediff-show-registry'
  350.      This command brings up the registry of active Ediff sessions.
  351.      Ediff registry is a useful device that can be used for resuming
  352.      Ediff sessions when the user switched to some other work before
  353.      finishing a comparison or merging job.  It is also useful for
  354.      switching between multiple active Ediff sessions that are run at
  355.      the same time. The function `eregistry' is an alias for
  356.      `ediff-show-registry'.
  357.  
  358. `ediff-toggle-multiframe'
  359.      Changes the display from the multi-frame mode (where the quick
  360.      help window is in a separate frame) to the single-frame mode
  361.      (where all Ediff buffers share the same frame), and vice versa.
  362.  
  363. `ediff-revert-buffers-then-recompute-diffs'
  364.      This command reverts the buffers you are comparing and recomputes
  365.      their differences.  It is useful when, after making changes, you
  366.      decided to make a fresh start, or if at some point you changed the
  367.      files being compared but want to discard any changes to comparison
  368.      buffers that were done since then.
  369.  
  370.      This command normally asks for confirmation before reverting files.
  371.      With a prefix argument, it reverts files without asking.
  372.  
  373. `ediff-profile'
  374.      Ediff has an admittedly primitive (but useful) facility for
  375.      profiling Ediff's commands.  It is meant for Ediff
  376.      maintenance--specifically, for making it run faster.  The function
  377.      `ediff-profile' toggles profiling of ediff commands.
  378.  
  379. 
  380. File: ediff,  Node: Registry of Ediff Sessions,  Next: Session Groups,  Prev: Commands,  Up: Top
  381.  
  382. Registry of Ediff Sessions
  383. **************************
  384.  
  385.    Ediff maintains a registry of all its invocations that are still
  386. *active*. This feature is very convenient for switching among active
  387. Ediff sessions or for quickly restarting a suspended Ediff session.
  388.  
  389.    The focal point of this activity is a buffer called **Ediff
  390. Registry**. You can display this buffer by typing `R' in any Ediff
  391. Control Buffer or Session Group Buffer (*note Session Groups::.), or by
  392. typing `M-x eregistry' into the Minibuffer.  The latter would be the
  393. fastest way to bring up the registry buffer if no control or group
  394. buffer is displayed in any of the visible Emacs windows.  If you are in
  395. a habit of running multiple long Ediff sessions and often need to
  396. suspend, resume, or switch between them, it may be a good idea to have
  397. the registry buffer permanently displayed in a separate, dedicated
  398. window.
  399.  
  400.    The registry buffer has several convenient key bindings.  For
  401. instance, clicking mouse button 2 or typing `RET' or `v' over any
  402. session record resumes that session.  Session records in the registry
  403. buffer provide a fairly complete description of each session, so it is
  404. usually easy to identify the right session to resume.
  405.  
  406.    Other useful commands are bound to `SPC' (next registry record) and
  407. `DEL' (previous registry record). There are other commands as well, but
  408. you don't need to memorize them, since they are listed at the top of
  409. the registry buffer.
  410.  
  411. 
  412. File: ediff,  Node: Session Groups,  Next: Remote and Compressed Files,  Prev: Registry of Ediff Sessions,  Up: Top
  413.  
  414. Session Groups
  415. **************
  416.  
  417.    Several major entries of Ediff perform comparison and merging on
  418. directories.  On entering `ediff-directories', `ediff-directories3',
  419. `ediff-merge-directories', `ediff-merge-directories-with-ancestor',
  420. `ediff-directory-revisions', `ediff-merge-directory-revisions', or
  421. `ediff-merge-directory-revisions-with-ancestor', the user is presented
  422. with a Dired-like buffer that lists files common to the directories
  423. involved along with their sizes. (The list of common files can be
  424. further filtered through a regular expression, which the user is
  425. prompted for.) We call this buffer *Session Group Panel* because all
  426. Ediff sessions associated with the listed files will have this buffer
  427. as a common focal point.
  428.  
  429.    Clicking button 2 or typing `RET' or `v' over a record describing
  430. files invokes Ediff in the appropriate mode on these files. You can
  431. come back to the session group buffer associated with a particular
  432. invocation of Ediff by typing `M' in Ediff control buffer of that
  433. invocation.
  434.  
  435.    Many commands are available in the session group buffer; some are
  436. applicable only for certain types of work. The relevant commands are
  437. always listed at the top of each session group buffer, so there is no
  438. need to memorize them.
  439.  
  440.    In directory comparison or merging, a session group panel displays
  441. only the files common to all directories involved. The differences are
  442. kept in a separate buffer and are conveniently displayed by typing `D'
  443. to the corresponding session group panel. Thus, as an added benefit,
  444. Ediff can be used to compare the contents of up to three directories.
  445.  
  446.    Session records in session group panels are also marked with `+', for
  447. active sessions, and with `-', for finished sessions.
  448.  
  449.    Sometimes, it is convenient to exclude certain session records from
  450. a group.  Usually this happens when the user doesn't intend to run
  451. Ediff of certain files in the group, and the corresponding session
  452. records just add clutter to the session group buffer. To help alleviate
  453. this problem, the user can type `h' to mark a session as a candidate
  454. for exclusion and `x' to actually hide the marked sessions. There
  455. actions are reversible: with a prefix argument, `h' unmarks the session
  456. under the cursor, and `x' brings the hidden sessions into the view (`x'
  457. doesn't unmark them, though, so the user has to explicitly unmark the
  458. sessions of interest).
  459.  
  460.    Group sessions also understand the command `m', which marks sessions
  461. for future operations (other than hiding) on a group of sessions. At
  462. present, the only such group-level operation is the creation of a
  463. multi-file patch.
  464.  
  465.    A multi-file patch is a concatenated output of several runs of the
  466. Unix `diff' command (some versions of `diff' let you create a
  467. multi-file patch in just one run).  In a session group buffer created in
  468. response to `ediff-directories' or `ediff-directory-revisions', the
  469. user can type `P' to create a multi-file patch of marked sessions
  470. (which must be marked using the `m' command).  Ediff then will display
  471. a buffer containing the patch.  In an `ediff-directories' session, it
  472. is enough to just mark the requisite sessions. In
  473. `ediff-directory-revisions' revisions, the marked sessions must also be
  474. active, or else Ediff will refuse to produce a multi-file patch. This is
  475. because, in the latter-style sessions, there are many ways to create
  476. diff output, and it is easier to handle by running Ediff on the inactive
  477. sessions.
  478.  
  479. 
  480. File: ediff,  Node: Remote and Compressed Files,  Next: Customization,  Prev: Session Groups,  Up: Top
  481.  
  482. Remote and Compressed Files
  483. ***************************
  484.  
  485.    Ediff works with remote, compressed, and encrypted files.  Ediff
  486. supports `ange-ftp.el', `jka-compr.el', `uncompress.el' and
  487. `crypt++.el', but it may work with other similar packages as well.
  488. This means that you can compare files residing on another machine, or
  489. you can apply a patch to a file on another machine.  Even the patch
  490. itself can be a remote file!
  491.  
  492.    When patching compressed or remote files, Ediff does not rename the
  493. source file (unlike what the `patch' utility would usually do).
  494. Instead, the source file retains its name and the result of applying
  495. the patch is placed in a temporary file that has the suffix `_patched'
  496. attached.  Generally, this applies to files that are handled using
  497. black magic, such as special file handlers (ange-ftp and some
  498. compression and encryption packages all use this method).
  499.  
  500.    Regular files are treated by the `patch' utility in the usual manner,
  501. i.e., the original is renamed into `source-name.orig' and the result of
  502. the patch is placed into the file source-name. (Ediff `_orig' on
  503. systems like VMS, DOS, etc.)
  504.  
  505. 
  506. File: ediff,  Node: Customization,  Next: Credits,  Prev: Remote and Compressed Files,  Up: Top
  507.  
  508. Customization
  509. *************
  510.  
  511.    Ediff has a rather self-explanatory interface, and in most cases you
  512. won't need to change anything.  However, should the need arise, there
  513. are extensive facilities to change the default behavior.
  514.  
  515.    Most of the customization can be done by setting various variables
  516. in the `.emacs' file. Some customization (mostly window-related
  517. customization and faces) can be done by putting appropriate lines in
  518. `.Xdefaults', `.xrdb', or whatever X resource file is in use.
  519.  
  520.    With respect to the latter, please note that the X resource for
  521. Ediff customization is `Ediff', *not* `emacs'.  *Note Window and Frame
  522. Configuration::, *Note Highlighting Difference Regions::, for further
  523. details. Please also refer to Emacs manual for the information on how
  524. to set Emacs X resources.
  525.  
  526. * Menu:
  527.  
  528. * Hooks::                       Customization via the hooks.
  529. * Quick Help::                  How to customize Ediff's quick help feature.
  530. * Window and Frame Configuration::  Controlling the way Ediff displays things.
  531. * Selective Browsing::          Advanced browsing through difference regions.
  532. * Highlighting Difference Regions::  Controlling highlighting.
  533. * Narrowing::                   Comparing regions, windows, etc.
  534. * Refinement of Difference Regions::  How to control the refinement process.
  535. * Patch and Diff Programs::     Changing the utilities that compute differences
  536.                                 and apply patches.
  537. * Merging and diff3::           How to customize Ediff in its Merge Mode.
  538. * Support for Version Control::  Changing the version control package.
  539.                                  You are not likely to do that.
  540. * Customizing the Mode Line::   Changing the look of the mode line in Ediff.
  541. * Miscellaneous::               Other customization.
  542. * Notes on Heavy-duty Customization::  Customization for the gurus.
  543.  
  544. 
  545. File: ediff,  Node: Hooks,  Next: Quick Help,  Prev: Customization,  Up: Customization
  546.  
  547. Hooks
  548. =====
  549.  
  550.    The bulk of customization can be done via the following hooks:
  551.  
  552. `ediff-load-hook'
  553.      This hook can be used to change defaults after Ediff is loaded.
  554.  
  555. `ediff-keymap-setup-hook'
  556.      This hook can be used to alter bindings in Ediff's keymap. These
  557.      hooks are run right after the default bindings are set but before
  558.      `ediff-load-hook'.  The regular user needs not be concerned with
  559.      this hook--it is provided for implementors of other Emacs packages
  560.      built on top of Ediff.
  561.  
  562. `ediff-before-setup-windows-hook'
  563. `ediff-after-setup-windows-hook'
  564.      These two hooks are called before and after Ediff sets up its
  565.      window configuration.  Can be used to save the configuration that
  566.      existed before Ediff starts or for whatever other purposes.
  567.  
  568. `ediff-suspend-hook'
  569. `ediff-quit-hook'
  570.      These two hooks are run when you suspend or quit Ediff.  They can
  571.      be used to set desired window configurations, delete files Ediff
  572.      didn't want to clean up after exiting, etc.
  573.  
  574.      By default, `ediff-quit-hook' holds one hook function,
  575.      `ediff-cleanup-mess', which cleans after Ediff, as appropriate in
  576.      most cases.  You probably won't want to change it, but you might
  577.      want to add other hook functions.
  578.  
  579.      Keep in mind that hooks executing before `ediff-cleanup-mess' start
  580.      in `ediff-control-buffer;' they should also leave
  581.      `ediff-control-buffer' as the current buffer when they finish.
  582.      Hooks that are executed after `ediff-cleanup-mess' should expect
  583.      the current buffer be either buffer A or buffer B.
  584.      `ediff-cleanup-mess' doesn't kill the buffers being compared or
  585.      merged (see `ediff-cleanup-hook', below).
  586.  
  587. `ediff-cleanup-hook'
  588.      This hook is run just before `ediff-quit-hook'.  This is a good
  589.      place to do various cleanups, such as deleting the variant buffers.
  590.      Ediff provides a function, `ediff-janitor', as one such possible
  591.      hook, which you can add to `ediff-cleanup-hook' with `add-hooks'.
  592.  
  593.      This function kills buffers A, B, and, possibly, C, if these
  594.      buffers aren't modified. In merge jobs, buffer C is never deleted.
  595.      However, the side effect of using this function is that you may
  596.      not be able to compare the same buffer in two separate Ediff
  597.      sessions: quitting one of them will delete this buffer in another
  598.      session as well.
  599.  
  600. `ediff-before-setup-control-frame-hook'
  601. `ediff-after-setup-control-frame-hook'
  602.      These two hooks run before and after Ediff sets up the control
  603.      frame.  They can be used to relocate Ediff control frame when
  604.      Ediff runs in a multiframe mode (i.e., when the control buffer is
  605.      in its own dedicated frame).  Be aware that many variables that
  606.      drive Ediff are local to Ediff Control Panel
  607.      (`ediff-control-buffer'), which requires special care in writing
  608.      these hooks.  Take a look at `ediff-default-suspend-hook' and
  609.      `ediff-default-quit-hook' to see what's involved.
  610.  
  611. `ediff-startup-hook'
  612.      This hook is run at the end of Ediff startup.
  613.  
  614. `ediff-select-hook'
  615.      This hook is run after Ediff selects the next difference region.
  616.  
  617. `ediff-unselect-hook'
  618.      This hook is run after Ediff unselects the current difference
  619.      region.
  620.  
  621. `ediff-prepare-buffer-hook'
  622.      This hook is run for each Ediff buffer (A, B, C) right after the
  623.      buffer is arranged.
  624.  
  625. `ediff-display-help-hook'
  626.      Ediff runs this hook each time after setting up the help message.
  627.      It can be used to alter the help message for custom packages that
  628.      run on top of Ediff.
  629.  
  630. `ediff-mode-hook'
  631.      This hook is run just after Ediff mode is set up in the control
  632.      buffer. This is done before any Ediff window is created. You can
  633.      use it to set local variables that alter the look of the display.
  634.  
  635. `ediff-registry-setup-hook'
  636.      Hooks run after setting up the registry for all active Ediff
  637.      session.  *Note Session Groups::, for details.
  638.  
  639. `ediff-session-group-setup-hook'
  640.      Hooks run after setting up a control panel for a group of related
  641.      Ediff sessions. *Note Session Groups::, for details.
  642.  
  643. 
  644. File: ediff,  Node: Quick Help,  Next: Window and Frame Configuration,  Prev: Hooks,  Up: Customization
  645.  
  646. Quick Help
  647. ==========
  648.  
  649.    Ediff provides quick help using its control panel window. Since this
  650. window takes a fair share of the screen real estate, you can toggle it
  651. off by typing `?'.  The control window will then shrink to just one
  652. line and a mode line, displaying a short help message.
  653.  
  654.    The variable `ediff-use-long-help-message' tells Ediff whether you
  655. use the short message or the long one.  By default, it is set to `nil',
  656. meaning that the short message is used.  Set this to `t', if you want
  657. Ediff to use the long message by default. This property can always be
  658. changed interactively, by typing `?' into Ediff Control Buffer.
  659.  
  660.    If you want to change the appearance of the help message on a
  661. per-buffer basis, you must use `ediff-startup-hook' to change the value
  662. of the variable `ediff-help-message', which is local to
  663. `ediff-control-buffer'.
  664.  
  665. 
  666. File: ediff,  Node: Window and Frame Configuration,  Next: Selective Browsing,  Prev: Quick Help,  Up: Customization
  667.  
  668. Window and Frame Configuration
  669. ==============================
  670.  
  671.    On a non-windowing display, Ediff sets things up in one frame,
  672. splitting it between a small control window and the windows for buffers
  673. A, B, and C.  The split between these windows can be horizontal or
  674. vertical, which can be changed interactively by typing `|' while the
  675. cursor is in the control window.
  676.  
  677.    On a window display, Ediff sets up a dedicated frame for Ediff
  678. Control Panel and then it chooses windows as follows: If one of the
  679. buffers is invisible, it is displayed in the currently selected frame.
  680. If a buffer is visible, it is displayed in the frame where it is
  681. visible.  If, according to the above criteria, the two buffers fall
  682. into the same frame, then so be it--the frame will be shared by the
  683. two.  The same algorithm works when you type `C-l' (`ediff-recenter'),
  684. `p' (`ediff-previous-difference'), `n' (`ediff-next-difference'), etc.
  685.  
  686.    The above behavior also depends on whether the current frame is
  687. splittable, dedicated, etc. Unfortunately, the margin is too small to
  688. present this remarkable algorithm.
  689.  
  690.    The bottom line of all this is that you can compare buffers in one
  691. frame or in different frames.  The former is done by default, while the
  692. latter can be achieved by arranging buffers A, B (and C, if applicable)
  693. to be seen in different frames.  Ediff respects these arrangements,
  694. automatically adapting itself to the multi-frame mode.
  695.  
  696.    Ediff uses the following variables to set up its control panel
  697. (a.k.a. control buffer, a.k.a. quick help window):
  698.  
  699. `ediff-control-frame-parameters'
  700.      You can change or augment this variable including the font, color,
  701.      etc.  The X resource name of Ediff Control Panel frames is
  702.      `Ediff'.  Under X-windows, you can use this name to set up
  703.      preferences in your `~/.Xdefaults', `~/.xrdb', or whatever X
  704.      resource file is in use. Usually this is preferable to changing
  705.      `ediff-control-frame-parameters' directly.  For instance, you can
  706.      specify in `~/.Xdefaults' the color of the control frame using the
  707.      resource `Ediff*background'.
  708.  
  709.      In general, any X resource pertaining the control frame can be
  710.      reached via the prefix `Ediff*'.
  711.  
  712. `ediff-control-frame-position-function'
  713.      The preferred way of specifying the position of the control frame
  714.      is by setting the variable `ediff-control-frame-position-function'
  715.      to an appropriate function.  The default value of this variable is
  716.      `ediff-make-frame-position'. This function places the control
  717.      frame in the vicinity of the North-East corner of the frame
  718.      displaying buffer A.
  719.  
  720.    The following variables can be used to adjust the location produced
  721. by `ediff-make-frame-position' and for related customization.
  722.  
  723. `ediff-narrow-control-frame-leftward-shift'
  724.      Specifies the number of characters for shifting the control frame
  725.      from the rightmost edge of frame A when the control frame is
  726.      displayed as a small window.
  727.  
  728. `ediff-wide-control-frame-rightward-shift'
  729.      Specifies the rightward shift of the control frame from the left
  730.      edge of frame A when the control frame shows the full menu of
  731.      options.
  732.  
  733. `ediff-control-frame-upward-shift'
  734.      Specifies the number of pixels for the upward shift of the control
  735.      frame.
  736.  
  737. `ediff-prefer-iconified-control-frame'
  738.      If this variable is `t', the control frame becomes iconified
  739.      automatically when you toggle the quick help message off.  This
  740.      saves valuable real estate on the screen.  Toggling help back will
  741.      deiconify the control frame.
  742.  
  743.      To start Ediff with an iconified Control Panel, you should set this
  744.      variable to `t' and `ediff-prefer-long-help-message' to `nil'
  745.      (*note Quick Help::.).  This behavior is useful only if the window
  746.      manager is TWM or a derivative. Also, this doesn't work under
  747.      XEmacs, since this editor ignores input from icons.
  748.  
  749.    To make more creative changes in the way Ediff sets up windows, you
  750. can rewrite the function `ediff-setup-windows'.  However, we believe
  751. that detaching Ediff Control Panel from the rest and making it into a
  752. separate frame offers an important opportunity by allowing you to
  753. iconify that frame.  Under Emacs, the icon will usually accept all of
  754. the Ediff commands, but will free up valuable real estate on your screen
  755. (this may depend on the window manager, though).  Iconifying won't do
  756. any good under XEmacs since XEmacs icons are not sensitive to keyboard
  757. input.  The saving grace is that, even if not iconified, the control
  758. frame is very small, smaller than some icons, so it does not take much
  759. space in any case.
  760.  
  761.    The following variable controls how windows are set up:
  762.  
  763. `ediff-window-setup-function'
  764.      The multiframe setup is done by the
  765.      `ediff-setup-windows-multiframe' function, which is the default on
  766.      windowing displays.  The plain setup, one where all windows are
  767.      always in one frame, is done by `ediff-setup-windows-plain', which
  768.      is the default on a non-windowing display (or in an xterm window).
  769.      In fact, under Emacs, you can switch freely between these two
  770.      setups by executing the command `ediff-toggle-multiframe' using
  771.      the Minibuffer.
  772.  
  773.      If you don't like any of these setups, write your own function.
  774.      See the documentation for `ediff-window-setup-function' for the
  775.      basic guidelines.  However, writing window setups is not easy, so
  776.      you should first take a close look at `ediff-setup-windows-plain'
  777.      and `ediff-setup-windows-multiframe'.
  778.  
  779.    You can run multiple Ediff sessions at once, by invoking Ediff
  780. several times without exiting previous Ediff sessions.  Different
  781. sessions may even operate on the same pair of files.
  782.  
  783.    Each session has its own Ediff Control Panel and all the regarding a
  784. particular session is local to the associated control panel buffer.  You
  785. can switch between sessions by suspending one session and then switching
  786. to another control panel.  (Different control panel buffers are
  787. distinguished by a numerical suffix, e.g., `Ediff Control Panel<3>'.)
  788.  
  789. 
  790. File: ediff,  Node: Selective Browsing,  Next: Highlighting Difference Regions,  Prev: Window and Frame Configuration,  Up: Customization
  791.  
  792. Selective Browsing
  793. ==================
  794.  
  795.    Sometimes it is convenient to be able to step through only some
  796. difference regions, those that satisfy certain regular expressions, and
  797. to ignore all others.  On other occasions, you may want to ignore
  798. difference regions that satisfy some regular expressions, and to look
  799. only at the rest.
  800.  
  801.    The commands `#f' and `#h' let you do precisely this.
  802.  
  803.    Typing `#f' lets you specify regular expressions that match
  804. difference regions you want to focus on.  We shall call these regular
  805. expressions REGEXP-A, REGEXP-B and REGEXP-C.  Ediff will then start
  806. stepping through only those difference regions where the region in
  807. buffer A matches REGEXP-A and/or the region in buffer B matches
  808. REGEXP-B, etc.  Whether `and' or `or' will be used depends on how you
  809. respond to a question.
  810.  
  811.    When scanning difference regions for the aforesaid regular
  812. expressions, Ediff narrows the buffers to those regions. This means
  813. that you can use the expressions `\`' and `\'' to tie search to the
  814. beginning or end of the difference regions.
  815.  
  816.    On the other hand, typing `#h' lets you specify (hide) uninteresting
  817. regions. That is, if a difference region in buffer A matches REGEXP-A,
  818. the corresponding region in buffer B matches REGEXP-B and (if
  819. applicable) buffer-C's region matches REGEXP-C, then the region will be
  820. ignored by the commands `n'/SPC (`ediff-next-difference') and `p'/DEL
  821. (`ediff-previous-difference') commands.
  822.  
  823.    Typing `#f' and `#h' toggles selective browsing on and off.
  824.  
  825.    Note that selective browsing affects only `ediff-next-difference'
  826. and `ediff-previous-difference', i.e., the commands `n'/SPC and
  827. `p'/DEL.  `#f' and `#h' do not change the position of the point in the
  828. buffers.  And you can still jump directly (using `j')  to any numbered
  829. difference.
  830.  
  831.    Users can supply their own functions to specify how Ediff should do
  832. selective browsing. To change the default Ediff function, add a
  833. function to `ediff-load-hook' which will do the following assignments:
  834.  
  835.      (setq ediff-hide-regexp-matches-function 'your-hide-function)
  836.      (setq ediff-focus-on-regexp-matches-function 'your-focus-function)
  837.  
  838.    *Useful hint*: To specify a regexp that matches everything, don't
  839. simply type RET in response to a prompt. Typing RET tells Ediff to
  840. accept the default value, which may not be what you want. Instead, you
  841. should enter something like ^ or $. These match every line.
  842.  
  843.    You can use the status command, `i', to find out whether selective
  844. browsing is currently in use.
  845.  
  846.    The regular expressions you specified are kept in the local variables
  847. `ediff-regexp-focus-A', `ediff-regexp-focus-B', `ediff-regexp-focus-C',
  848. `ediff-regexp-hide-A', `ediff-regexp-hide-B', `ediff-regexp-hide-C'.
  849. Their default value is the empty string (i.e., nothing is hidden or
  850. focused on).  To change the default, set these variables in `.emacs'
  851. using `setq-default'.
  852.  
  853.    In addition to the ability to ignore regions that match regular
  854. expressions, Ediff can be ordered to start skipping over certain
  855. "inessential" regions.  This is controlled by the following variable:
  856.  
  857. `ediff-ignore-similar-regions'
  858.      If `t', causes Ediff to skip over difference regions that deemed
  859.      inessential, i.e., where the only differences are those in the
  860.      white space and newlines.
  861.  
  862.    *Note:* In order for this feature to work, auto-refining of
  863. difference regions must be on, since otherwise Ediff won't know if there
  864. are fine differences between regions.  On devices where Emacs can
  865. display faces, auto-refining is a default, but it is not turned on by
  866. default on text-only terminals.  In that case, you must explicitly turn
  867. auto-refining on (such as, by typing `@').
  868.  
  869.    *Reassurance:* If many inessential regions appear in a row, Ediff may
  870. take a long time to jump to the next region because it has to compute
  871. fine differences of all intermediate regions.  This delay does not
  872. indicate any problem.
  873.  
  874. 
  875. File: ediff,  Node: Highlighting Difference Regions,  Next: Narrowing,  Prev: Selective Browsing,  Up: Customization
  876.  
  877. Highlighting Difference Regions
  878. ===============================
  879.  
  880.    The following variables control the way Ediff highlights difference
  881. regions:
  882.  
  883. `ediff-before-flag-bol'
  884. `ediff-after-flag-eol'
  885. `ediff-before-flag-mol'
  886. `ediff-after-flag-mol'
  887.      These variables hold strings that Ediff uses to mark the beginning
  888.      and the end of the differences found in files A, B, and C on
  889.      devices where Emacs cannot display faces. Ediff uses different
  890.      flags to highlight regions that begin/end at the beginning/end of
  891.      a line or in a middle of a line.
  892.  
  893. `ediff-current-diff-face-A'
  894. `ediff-current-diff-face-B'
  895. `ediff-current-diff-face-C'
  896.      Ediff uses these faces to highlight current differences on devices
  897.      where Emacs can display faces.  These and subsequently described
  898.      faces can be set either in `.emacs' or in `.Xdefaults'. The X
  899.      resource for Ediff is `Ediff', *not* `emacs'. Please refer to
  900.      Emacs manual for the information on how to set X resources.
  901.  
  902. `ediff-fine-diff-face-A'
  903. `ediff-fine-diff-face-B'
  904. `ediff-fine-diff-face-C'
  905.      Ediff uses these faces to show the fine differences between the
  906.      current differences regions in buffers A, B, and C, respectively.
  907.  
  908. `ediff-even-diff-face-A'
  909. `ediff-even-diff-face-B'
  910. `ediff-even-diff-face-C'
  911. `ediff-odd-diff-face-A'
  912. `ediff-odd-diff-face-B'
  913. `ediff-odd-diff-face-C'
  914.      Non-current difference regions are displayed using these
  915.      alternating faces. The odd and the even faces are actually
  916.      identical on monochrome displays, because without colors options
  917.      are limited.  So, Ediff uses italics to highlight non-current
  918.      differences.
  919.  
  920. `ediff-force-faces'
  921.      Ediff generally can detect when Emacs is running on a device where
  922.      it can use highlighting with faces. However, if it fails to
  923.      determine that faces can be used, the user can set this variable
  924.      to `t' to make sure that Ediff uses faces to highlight differences.
  925.  
  926. `ediff-highlight-all-diffs'
  927.      Indicates whether--on a window system--Ediff should highlight
  928.      differences using inserted strings (as on a text-only terminal) or
  929.      using colors and highlighting.  Normally, Ediff highlights all
  930.      differences, but the selected difference is highlighted more
  931.      visibly.  One can cycle through various modes of highlighting by
  932.      typing `h'.  By default, Ediff starts in the mode where all
  933.      difference regions are highlighted.  If you prefer to start in the
  934.      mode where unselected differences are not highlighted, you should
  935.      set `ediff-highlight-all-diffs' to `nil'.  Type `h' to restore
  936.      highlighting of all differences.
  937.  
  938.      Ediff lets you switch between the two modes of highlighting.  That
  939.      is, you can switch interactively from highlighting using faces to
  940.      highlighting using string flags, and back.  Of course, switching
  941.      has effect only under a windowing system.  On a text-only terminal
  942.      or in an xterm window, the only available option is highlighting
  943.      with strings.
  944.  
  945. If you want to change the above variables, you must do it *before*
  946. Ediff is loaded.
  947.  
  948.    There are two ways to change the default setting for highlighting
  949. faces: either change the variables, as shown here,
  950.  
  951.      (setq ediff-current-diff-face-A 'bold-italic)
  952.  
  953. or here,
  954.  
  955.      (setq ediff-current-diff-face-A
  956.      (copy-face 'bold-italic 'ediff-current-diff-face-A))
  957.  
  958. or modify the defaults selectively:
  959.  
  960.      (add-hook 'ediff-load-hook
  961.                (function (lambda ()
  962.                            (set-face-foreground
  963.                              ediff-current-diff-face-B "blue")
  964.                            (set-face-background
  965.                              ediff-current-diff-face-B "red")
  966.                            (make-face-italic
  967.                              ediff-current-diff-face-B))))
  968.  
  969.    You may also want to take a look at how the above faces are defined
  970. in the source code of Ediff.
  971.  
  972.    *Note:* it is not recommended to use `internal-get-face' (or
  973. `get-face' in XEmacs) when defining Ediff's faces, since this may cause
  974. problems when there are several frames with different font sizes.
  975. Instead, use `copy-face' or `set/make-face-...' as shown above.
  976.  
  977. 
  978. File: ediff,  Node: Narrowing,  Next: Refinement of Difference Regions,  Prev: Highlighting Difference Regions,  Up: Customization
  979.  
  980. Narrowing
  981. =========
  982.  
  983.    If buffers being compared are narrowed at the time of invocation of
  984. Ediff, `ediff-buffers' will preserve the narrowing range.  However, if
  985. `ediff-files' is invoked on the files visited by these buffers, that
  986. widens the buffers, since this command is defined to compare the entire
  987. files.
  988.  
  989.    Calling `ediff-regions-linewise' or `ediff-windows-linewise', or the
  990. corresponding `-wordwise' commands, narrows the buffers being compared
  991. (corresponding to the regions being compared).  The original accessible
  992. ranges are restored when you quit Ediff.  During the command, you can
  993. toggle this narrowing on and off with the `%' command.
  994.  
  995.    These two variables control this narrowing behavior:
  996.  
  997. `ediff-start-narrowed'
  998.      If `t', Ediff narrows the display to the appropriate range when it
  999.      is invoked with an `ediff-regions...' or `ediff-windows...'
  1000.      command.  If `nil', these commands do not automatically narrow,
  1001.      but you can still toggle narrowing on and off by typing `%'.
  1002.  
  1003. `ediff-quit-widened'
  1004.      Controls whether on quitting Ediff should restore the accessible
  1005.      range that existed before the current invocation.
  1006.  
  1007. 
  1008. File: ediff,  Node: Refinement of Difference Regions,  Next: Patch and Diff Programs,  Prev: Narrowing,  Up: Customization
  1009.  
  1010. Refinement of Difference Regions
  1011. ================================
  1012.  
  1013.    Ediff has variables to control the way fine differences are
  1014. highlighted.  This feature gives you control over the process of
  1015. refinement.  Note that refinement ignores spaces, tabs, and newlines.
  1016.  
  1017. `ediff-auto-refine'
  1018.      This variable controls whether fine differences within regions are
  1019.      highlighted automatically ("auto-refining").  The default is yes
  1020.      (`on').
  1021.  
  1022.      On a slow machine, automatic refinement may be painful.  In that
  1023.      case, you can turn auto-refining on or off interactively by typing
  1024.      `@'.  You can also turn off display of refining that has already
  1025.      been done.
  1026.  
  1027.      When auto-refining is off, fine differences are shown only for
  1028.      regions for which these differences have been computed and saved
  1029.      before.  If auto-refining and display of refining are both turned
  1030.      off, fine differences are not shown at all.
  1031.  
  1032.      Typing `*' computes and displays fine differences for the current
  1033.      difference region, regardless of whether auto-refining is turned
  1034.      on.
  1035.  
  1036. `ediff-auto-refine-limit'
  1037.      If auto-refining is on, this variable limits the size of the
  1038.      regions to be auto-refined.  This guards against the possible
  1039.      slowdown that may be caused by extraordinary large difference
  1040.      regions.
  1041.  
  1042.      You can always refine the current region by typing `*'.
  1043.  
  1044. `ediff-forward-word-function'
  1045.      This variable gives control over how fine differences are
  1046.      computed.  The value must be a Lisp function that determines how
  1047.      the current difference region should be split into words.
  1048.  
  1049.      Fine differences are computed by first splitting the current
  1050.      difference region into words and then passing this along to
  1051.      `ediff-diff-program'. For the default
  1052.      `ediff-forward-word-function' (which is `ediff-forward-word'), a
  1053.      word is a string consisting of letters, `-', or `_'; a string of
  1054.      punctuation symbols; a string of digits, or a string consisting of
  1055.      symbols that are neither space, nor a letter.
  1056.  
  1057.      This default behavior is controlled by four variables:
  1058.      `ediff-word-1', ..., `ediff-word-4'. See the on-line documentation
  1059.      for these variables and for the function `ediff-forward-word' for
  1060.      an explanation of how to modify these variables.
  1061.  
  1062.    Sometimes, when a region has too many differences between the
  1063. variants, highlighting of fine differences is inconvenient, especially
  1064. on color displays.  If that is the case, type `*' with a negative
  1065. prefix argument.  This unhighlights fine differences for the current
  1066. region.
  1067.  
  1068.    To unhighlight fine differences in all difference regions, use the
  1069. command `@'.  Repeated typing of this key cycles through three
  1070. different states: auto-refining, no-auto-refining, and no-highlighting
  1071. of fine differences.
  1072.  
  1073.